package com.thx.tags;

import com.opensymphony.xwork2.util.ValueStack;

import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ComponentTagSupport;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 自定义select标签.
 *
 * @author shiyan
 */
public class SelectTag extends ComponentTagSupport {

  private String name;

  private String type;

  private String value;

  private String dicCode;

  private String valField;//指定select->option的value值来源的实体字段

  private boolean noDefault;

  @Override
  public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
    return new Select(stack);
  }


  public String getName() {
    return name;
  }

  protected void populateParams() {
    super.populateParams();
    Select select = (Select) component;
    select.setName(name);
    select.setType(type);
    select.setValue(value);
    select.setDicCode(dicCode);
    select.setNoDefault(noDefault);
    select.setValField(valField);
  }

  public void setName(String name) {
    this.name = name;
  }


  public String getType() {
    return type;
  }


  public void setType(String type) {
    this.type = type;
  }


  public String getValue() {
    return value;
  }


  public void setValue(String value) {
    this.value = value;
  }


  public String getDicCode() {
    return dicCode;
  }


  public void setDicCode(String dicCode) {
    this.dicCode = dicCode;
  }


  public boolean getNoDefault() {
    return noDefault;
  }


  public void setNoDefault(boolean noDefault) {
    this.noDefault = noDefault;
  }


  public String getValField() {
    return valField;
  }


  public void setValField(String valField) {
    this.valField = valField;
  }

}
